<?php

class Home extends MY_Controller 
{
	
	function Home()
	{
		parent::MY_Controller();
		
		header('Expires: Thu, 01-Jan-70 00:00:01 GMT');
		header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
		header('Cache-Control: no-store, no-cache, must-revalidate');
		header('Pragma: no-cache');

		$this->data['header_data']['css'][] = '/css/home.css';
		$this->data['header_data']['js'][] = '/js/tmp.js';

		$this->load->library('form_validation');
			
		//$this->data['header_data']['js'][] = '/js/openid/openid-jquery.js';
		//$this->data['header_data']['js'][] = '/js/openid/openid-jquery-en.js';
	}
	
	function index()
	{	
		$this->load->library('user_agent');
		//echo $this->agent->browser() . ' : ' . (int)$this->agent->version(); die;
		
		$user_id = $this->session->userdata('user_id');
		if( (int)$user_id == 0 )
		{	
			# create new nonce for the login form
			$viewdata['nonce'] = md5(uniqid(rand(),true));
			$this->session->set_userdata('login_nonce', $viewdata['nonce']);			
			$this->data['content'] = $this->load->view('home-login', $viewdata, true);
		} 
		else
		{
			redirect( site_url('tasks'), 'location');
		}
		
		$this->data['no_sidebar'] = true;
		$this->load->view('global/master-view', $this->data);
	}
	
	/*
	public function terms()
	{
		$this->data['no_sidebar'] = true;
		$this->load->view('global/master-view', $this->data);
	}
	*/
}